package tech.chauncy.springbootwebsample.controller;

import javax.servlet.http.HttpServletRequest;

import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Properties;

@RestController
@RequestMapping("/hello")
public class HelloWorldController {


	@RequestMapping(value = "/csf_hfcx", method = RequestMethod.POST)
	public ResponseEntity<Object> isHaveBill(HttpServletRequest request,
											 @RequestBody(required = true) String jsonStr) throws Exception {

		JSONObject injson = new JSONObject(jsonStr);
		String userid = injson.getJSONObject("params").getString("tel");

		JSONObject subjson = new JSONObject();
		switch (userid) {
			case "1":
			case "2": {
				subjson.put("是否有话费信息", "true");
				subjson.put("累计消费", "66");
				subjson.put("话费余额", "88");
				subjson.put("是否欠费", "false");
				break;
			}
			case "3": {
				subjson.put("是否有话费信息", "false");
				subjson.put("累计消费", "");
				subjson.put("话费余额", "");
				subjson.put("是否欠费", "");
				break;
			}
			case "4":
			case "5":{
				subjson.put("是否有话费信息", "true");
				subjson.put("累计消费", "88");
				subjson.put("话费余额", "-1");
				subjson.put("是否欠费", "true");
				break;
			}
		}

		JSONObject json = new JSONObject();

		json.put("code", "0");
		json.put("message", "成功");
		json.put("result", subjson);
		return new ResponseEntity<Object>(json.toString(), HttpStatus.OK);

	}

	//停机判断
	@RequestMapping(value = "/csf_tjpd", method = RequestMethod.POST)
	public ResponseEntity<Object> isStopService(HttpServletRequest request,
											 @RequestBody(required = true) String jsonStr) throws Exception {


		JSONObject injson = new JSONObject(jsonStr);
		String userid = injson.getJSONObject("params").getString("tel");;


		JSONObject subjson = new JSONObject();
		switch (userid) {
			case "1":
			case "4":
			case "6":
			case "9":
			case "12":
			case "15":
			case "37":{
				subjson.put("是否停机", "true");
				break;
			}
			case "18":{
				subjson.put("是否停机", "true");
				subjson.put("停机原因", "未实名制停机");
				break;
			}
			case "30":{
				subjson.put("是否停机", "true");
				subjson.put("停机原因", "欠费停机");
				break;
			}
			case "32":{
				subjson.put("是否停机", "true");
				subjson.put("停机原因", "主动报停");
				break;
			}
			case "31":{
				subjson.put("是否停机", "true");
				subjson.put("停机原因", "其他原因");
				subjson.put("其他原因之具体", "之具体");
				break;
			}
			case "2":
			case "5":
			case "7":
			case "10":
			case "13":
			case "16":
			case "19":
			case "20":
			case "21":
			case "22":
			case "23":
			case "24":
			case "25":
			case "60":
			case "26":
			case "27":
			case "28":
			case "29":
			case "33":
			case "34":
			case "35":
			case "38":
			case "39":
			case "40":
			case "41":
			case "42":
			case "43":
			{
				subjson.put("是否停机", "false");
				break;
			}
		}

		JSONObject json = new JSONObject();

		json.put("code", "0");
		json.put("message", "成功");
		json.put("result", subjson);
		return new ResponseEntity<Object>(json.toString(), HttpStatus.OK);

	}

	@RequestMapping(value = "/csf_zdcx", method = RequestMethod.POST)
	public ResponseEntity<Object> getBill(HttpServletRequest request,
												@RequestBody(required = true) String jsonStr) throws Exception {


		JSONObject injson = new JSONObject(jsonStr);
		String userid = injson.getJSONObject("params").getString("tel");;


		JSONObject subjson = new JSONObject();
		switch (userid) {
			case "6":
			case "7": {
				subjson.put("是否有账单信息", "true");
				subjson.put("日期", "201711");
				subjson.put("累计消费", "4");
				subjson.put("套餐及固定费", "1");
				subjson.put("语音通话费", "3");
				subjson.put("上网费", "3");
				subjson.put("短信/彩信费", "3");
				subjson.put("增值业务费", "3");
				subjson.put("代收业务费", "3");
				subjson.put("其他费用", "3");
				subjson.put("优惠减免", "3");
				subjson.put("billcontent", "账单");
				subjson.put("tts_billcontent", "账单tts");
				break;
			}
			case "8": {
				subjson.put("是否有账单信息", "false");
				subjson.put("日期", "");
				subjson.put("累计消费", "");
				subjson.put("套餐及固定费", "");
				subjson.put("语音通话费", "");
				subjson.put("上网费", "");
				subjson.put("短信/彩信费", "");
				subjson.put("增值业务费", "");
				subjson.put("代收业务费", "");
				subjson.put("其他费用", "");
				subjson.put("优惠减免", "");
				break;
			}
		}

		JSONObject json = new JSONObject();

		json.put("code", "0");
		json.put("message", "成功");
		json.put("result", subjson);
		return new ResponseEntity<Object>(json.toString(), HttpStatus.OK);

	}

	@RequestMapping(value = "/csf_dxxf", method = RequestMethod.POST)
	public ResponseEntity<Object> sendMess(HttpServletRequest request,
												@RequestBody(required = true) String jsonStr) throws Exception {

		JSONObject subjson = new JSONObject();

		JSONObject json = new JSONObject();

		json.put("code", "0");
		json.put("message", "成功");
		json.put("result", subjson);
		return new ResponseEntity<Object>(json.toString(), HttpStatus.OK);

	}

	@RequestMapping(value = "/csf_ywnrfs", method = RequestMethod.POST)
	public ResponseEntity<Object> sendInfo(HttpServletRequest request,
										   @RequestBody(required = true) String jsonStr) throws Exception {

		JSONObject subjson = new JSONObject();

		JSONObject json = new JSONObject();

		json.put("code", "0");
		json.put("message", "成功");
		json.put("result", subjson);
		return new ResponseEntity<Object>(json.toString(), HttpStatus.OK);

	}

	@RequestMapping(value = "/csf_jfcx", method = RequestMethod.POST)
	public ResponseEntity<Object> hasJLService(HttpServletRequest request,
												@RequestBody(required = true) String jsonStr) throws Exception {


		JSONObject injson = new JSONObject(jsonStr);
		String userid = injson.getJSONObject("params").getString("tel");


		JSONObject subjson = new JSONObject();
		switch (userid) {
			case "9":
			case "10":
			{
				subjson.put("是否存在记录", "true");
				subjson.put("可用积分", "1234");
				break;
			}
			case "11":{
				subjson.put("是否存在记录", "false");
				break;
			}
		}

		JSONObject json = new JSONObject();

		json.put("code", "0");
		json.put("message", "成功");
		json.put("result", subjson);
		return new ResponseEntity<Object>(json.toString(), HttpStatus.OK);

	}

	@RequestMapping(value = "/csf_syllcx", method = RequestMethod.POST)
	public ResponseEntity<Object> hasTCJLService(HttpServletRequest request,
											   @RequestBody(required = true) String jsonStr) throws Exception {


		JSONObject injson = new JSONObject(jsonStr);
		String userid = injson.getJSONObject("params").getString("tel");


		JSONObject subjson = new JSONObject();
		switch (userid) {
			case "12":
			case "13":{
				{
					subjson.put("本月流量共计", "20");
					subjson.put("本月流量已使用", "4");
					subjson.put("本月流量剩余", "16");
					subjson.put("上月结转流量共计", "3");
					subjson.put("上月结转流量已使用", "2");
					subjson.put("上月结转流量剩余", "1");
					subjson.put("上月结转流量有效期", "201709");
					subjson.put("套餐", "43套餐");
					subjson.put("套餐内流量共计","43");
					subjson.put("套餐内流量已使用", "3");
					subjson.put("套餐内流量剩余", "40");
					subjson.put("流量包", "25流量包");
					subjson.put("流量包流量共计", "25");
					subjson.put("流量包流量已使用", "5");
					subjson.put("流量包流量剩余", "20");
					subjson.put("是否存在记录", "true");
					subjson.put("当前时间", "2017年12月14时15分48秒");
					subjson.put("语音套餐", "");
					subjson.put("语音套餐已使用", "");
					subjson.put("语音套餐剩余", "");
					subjson.put("短信套餐", "");
					subjson.put("短信套餐已使用", "");
					subjson.put("短信套餐剩余", "");
					subjson.put("彩信套餐", "");
					subjson.put("彩信套餐已使用", "");
					subjson.put("彩信套餐剩余", "");
					subjson.put("上网套餐", "");
					subjson.put("上网套餐已使用", "");
					subjson.put("上网套餐剩余", "");
					subjson.put("是否有上月流量结转", "false");
					break;
				}
			}
			case "15":
			case "16":
			{
				subjson.put("本月流量共计", "");
				subjson.put("本月流量已使用", "");
				subjson.put("本月流量剩余", "");
				subjson.put("上月结转流量共计", "");
				subjson.put("上月结转流量已使用", "");
				subjson.put("上月结转流量剩余", "");
				subjson.put("上月结转流量有效期", "");
				subjson.put("套餐", "");
				subjson.put("套餐内流量共计","");
				subjson.put("套餐内流量已使用", "");
				subjson.put("套餐内流量剩余", "");
				subjson.put("流量包", "");
				subjson.put("流量包流量共计", "");
				subjson.put("流量包流量已使用", "");
				subjson.put("流量包流量剩余", "");
				subjson.put("是否存在记录", "true");
				subjson.put("当前时间", "2017年12月14时15分48秒");
				subjson.put("语音套餐", "100语音套餐");
				subjson.put("语音套餐已使用", "80");
				subjson.put("语音套餐剩余", "20");
				subjson.put("短信套餐", "100短信");
				subjson.put("短信套餐已使用", "20");
				subjson.put("短信套餐剩余", "80");
				subjson.put("彩信套餐", "100彩信");
				subjson.put("彩信套餐已使用", "20");
				subjson.put("彩信套餐剩余", "80");
				subjson.put("上网套餐", "10上网");
				subjson.put("上网套餐已使用", "2");
				subjson.put("上网套餐剩余", "8");
				break;
			}
			case "14":
			case "17":{
				subjson.put("是否存在记录", "false");
				break;
			}
		}

		JSONObject json = new JSONObject();

		json.put("code", "0");
		json.put("message", "成功");
		json.put("result", subjson);
		return new ResponseEntity<Object>(json.toString(), HttpStatus.OK);

	}

	//是否实名
	@RequestMapping(value = "/csf_smrz", method = RequestMethod.POST)
	public ResponseEntity<Object> smrz(HttpServletRequest request,
										 @RequestBody(required = true) String jsonStr) throws Exception {


		JSONObject injson = new JSONObject(jsonStr);
		String userid = injson.getJSONObject("params").getString("tel");


		JSONObject subjson = new JSONObject();
		switch (userid) {
			case "19":
			case "38":
			{
				subjson.put("是否实名", "false");
				break;
			}
			case "20":
			case "21":
			case "22":
			case "23":
			case "24":
			case "25":
			case "60":
			case "26":
			case "27":
			case "28":
			case "29":
			case "39":
			case "40":
			case "41":
			case "42":
			case "35":
			{
				subjson.put("是否实名", "true");
				break;
			}
		}

		JSONObject json = new JSONObject();

		json.put("code", "0");
		json.put("message", "成功");
		json.put("result", subjson);
		return new ResponseEntity<Object>(json.toString(), HttpStatus.OK);

	}

	//密码是否锁定
	@RequestMapping(value = "/csf_mmsfsd", method = RequestMethod.POST)
	public ResponseEntity<Object> mmsfsd(HttpServletRequest request,
									   @RequestBody(required = true) String jsonStr) throws Exception {


		JSONObject injson = new JSONObject(jsonStr);
		String userid = injson.getJSONObject("params").getString("tel");


		JSONObject subjson = new JSONObject();
		switch (userid) {
			case "20":
			{
				subjson.put("密码是否锁定", "true");
				break;
			}
			case "21":
			case "22":
			case "23":
			case "24":
			case "25":
			case "60":
			case "26":
			case "27":
			case "28":
			case "29": {
				subjson.put("密码是否锁定", "false");
				break;
			}
		}

		JSONObject json = new JSONObject();

		json.put("code", "0");
		json.put("message", "成功");
		json.put("result", subjson);
		return new ResponseEntity<Object>(json.toString(), HttpStatus.OK);

	}

	//密码是否正确
	@RequestMapping(value = "/csf_mmsfzq", method = RequestMethod.POST)
	public ResponseEntity<Object> mmsfzq(HttpServletRequest request,
										 @RequestBody(required = true) String jsonStr) throws Exception {


		JSONObject injson = new JSONObject(jsonStr);
		String userid = injson.getJSONObject("params").getString("tel");


		JSONObject subjson = new JSONObject();
		switch (userid) {
			case "29":
			{
				subjson.put("密码是否正确", "false");
				break;
			}
			case "33":
			{
				subjson.put("密码是否正确", "false");
				subjson.put("累计错误次数", "1");
				break;
			}
			case "44":
			{
				subjson.put("密码是否正确", "false");
				subjson.put("累计错误次数", "2");
				break;
			}
			case "45":
			{
				subjson.put("密码是否正确", "false");
				subjson.put("累计错误次数", "3");
				break;
			}
			case "21":
			case "22":
			case "23":
			case "24":
			case "25":
			case "60":
			case "26":
			case "27":
			case "28":
			case "34":
			case "35":
			case "43":{
				subjson.put("密码是否正确", "true");
				break;
			}
		}

		JSONObject json = new JSONObject();

		json.put("code", "0");
		json.put("message", "成功");
		json.put("result", subjson);
		return new ResponseEntity<Object>(json.toString(), HttpStatus.OK);

	}


	//是否受理成功
	@RequestMapping(value = "/csf_bl4gtc", method = RequestMethod.POST)
	public ResponseEntity<Object> bl4gtc(HttpServletRequest request,
											   @RequestBody(required = true) String jsonStr) throws Exception {


		JSONObject injson = new JSONObject(jsonStr);
		String userid = injson.getJSONObject("params").getString("tel");


		JSONObject subjson = new JSONObject();
		switch (userid) {
			case "21":
			case "25":
			case "60":
			{
				subjson.put("办理成功", "true");
				subjson.put("失败原因", "");
				break;
			}
			case "22":
			case "26":{
				subjson.put("办理成功", "false");
				subjson.put("失败原因", "余额不足");
				break;
			}
			case "23":
			case "27":{
				subjson.put("办理成功", "false");
				subjson.put("失败原因", "系统繁忙");
				break;
			}
			case "24":
			case "28":{
				subjson.put("办理成功", "false");
				subjson.put("失败原因", "业务互斥");
				break;
			}
		}

		JSONObject json = new JSONObject();

		json.put("code", "0");
		json.put("message", "成功");
		json.put("result", subjson);
		return new ResponseEntity<Object>(json.toString(), HttpStatus.OK);

	}

	//是否有主菜单
	@RequestMapping(value = "/csf_maintc", method = RequestMethod.POST)
	public ResponseEntity<Object> maintc(HttpServletRequest request,
										 @RequestBody(required = true) String jsonStr) throws Exception {


		JSONObject injson = new JSONObject(jsonStr);
		String userid = injson.getJSONObject("params").getString("tel");


		JSONObject subjson = new JSONObject();
		switch (userid) {
			case "25":
			case "26":
			case "27":
			case "28":
			case "35":
			{
				subjson.put("是否有主套餐", "true");
				subjson.put("套餐名称", "4G飞享套餐");
				break;
			}
			case "60":
			{
				subjson.put("是否有主套餐", "true");
				subjson.put("套餐名称", "5G飞享套餐");
				break;
			}
			case "24":
			case "23":
			case "22":
			case "21":
			{
				subjson.put("是否有主套餐", "false");
				subjson.put("套餐名称", "");
				break;
			}
		}

		JSONObject json = new JSONObject();

		json.put("code", "0");
		json.put("message", "成功");
		json.put("result", subjson);

		JSONObject finaljson = new JSONObject();
		finaljson.put("returnCode",0);
		finaljson.put("beans",new JSONArray());
		finaljson.put("returnMessage","");
		finaljson.put("bean",json);

		return new ResponseEntity<Object>(json.toString(), HttpStatus.OK);

	}

	//停机原因判断
	@RequestMapping(value = "/csf_tjyypd", method = RequestMethod.POST)
	public ResponseEntity<Object> tjyypd(HttpServletRequest request,
										 @RequestBody(required = true) String jsonStr) throws Exception {


		JSONObject injson = new JSONObject(jsonStr);
		String userid = injson.getJSONObject("params").getString("tel");


		JSONObject subjson = new JSONObject();
		switch (userid) {
			case "18":
			{
				subjson.put("停机原因", "未实名制停机");
				break;
			}
			case "30": {
				subjson.put("停机原因", "欠费停机");
				break;
			}
			case "32": {
				subjson.put("停机原因", "主动报停");
				break;
			}
			case "31": {
				subjson.put("停机原因", "其他原因");
				subjson.put("其他原因之具体", "其他原因之具体");
				break;
			}
		}

		JSONObject json = new JSONObject();

		json.put("code", "0");
		json.put("message", "成功");
		json.put("result", subjson);
		return new ResponseEntity<Object>(json.toString(), HttpStatus.OK);

	}
	//密码修改是否成功
	@RequestMapping(value = "/csf_mmxg", method = RequestMethod.POST)
	public ResponseEntity<Object> mmxg(HttpServletRequest request,
										 @RequestBody(required = true) String jsonStr) throws Exception {


		JSONObject injson = new JSONObject(jsonStr);
		String userid = injson.getJSONObject("params").getString("tel");


		JSONObject subjson = new JSONObject();
		switch (userid) {
			case "34":
			{
				subjson.put("密码修改是否成功", "false");
				subjson.put("是否为弱密码", "true");
				break;
			}
			case "43":
			{
				subjson.put("密码修改是否成功", "false");
				subjson.put("是否为弱密码", "false");
				break;
			}
			case "35": {
				subjson.put("密码修改是否成功", "true");
				break;
			}
		}

		JSONObject json = new JSONObject();

		json.put("code", "0");
		json.put("message", "成功");
		json.put("result", subjson);
		return new ResponseEntity<Object>(json.toString(), HttpStatus.OK);

	}

	//证件号码是否正确
	@RequestMapping(value = "/csf_sfzyz", method = RequestMethod.POST)
	public ResponseEntity<Object> sfzyz(HttpServletRequest request,
									   @RequestBody(required = true) String jsonStr) throws Exception {


		JSONObject injson = new JSONObject(jsonStr);
		String userid = injson.getJSONObject("params").getString("tel");


		JSONObject subjson = new JSONObject();
		switch (userid) {
			case "39":
			{
				subjson.put("证件号码是否正确", "false");
				subjson.put("当天输入次数", "2");
				break;
			}
			case "40":
			 {
				subjson.put("证件号码是否正确", "false");
				subjson.put("当天输入次数", "3");
				break;
			 }
			case "41":
			case "42":
			{
				subjson.put("证件号码是否正确", "true");
				subjson.put("当天输入次数", "");
				break;
			}
		}

		JSONObject json = new JSONObject();

		json.put("code", "0");
		json.put("message", "成功");
		json.put("result", subjson);
		return new ResponseEntity<Object>(json.toString(), HttpStatus.OK);

	}


	@RequestMapping(value = "/csf_bjslyz", method = RequestMethod.POST)
	public ResponseEntity<Object> bjslyz(HttpServletRequest request,
										 @RequestBody(required = true) String jsonStr) throws Exception {


		JSONObject injson = new JSONObject(jsonStr);
		String userid = injson.getJSONObject("params").getString("tel");


		JSONObject subjson = new JSONObject();
		switch (userid) {
			case "33":
			case "36":
			{
				subjson.put("是否一致", "false");
				break;
			}
			case "37":
			case "38":
			case "39":
			case "40":
			case "41":
			case "42": {
				subjson.put("是否一致", "true");
				break;
			}
		}

		JSONObject json = new JSONObject();

		json.put("code", "0");
		json.put("message", "成功");
		json.put("result", subjson);
		return new ResponseEntity<Object>(json.toString(), HttpStatus.OK);

	}

	//密码重置是否成功
	@RequestMapping(value = "/csf_czpd", method = RequestMethod.POST)
	public ResponseEntity<Object> czpd(HttpServletRequest request,
									   @RequestBody(required = true) String jsonStr) throws Exception {


		JSONObject injson = new JSONObject(jsonStr);
		String userid = injson.getJSONObject("params").getString("tel");


		JSONObject subjson = new JSONObject();
		switch (userid) {
			case "41":
			{
				subjson.put("是否重置成功", "false");
				subjson.put("失败原因", "网络问题");
				break;
			}
			case "42": {
				subjson.put("是否重置成功", "true");
				subjson.put("失败原因", "");
				break;
			}
		}

		JSONObject json = new JSONObject();

		json.put("code", "0");
		json.put("message", "成功");
		json.put("result", subjson);
		return new ResponseEntity<Object>(json.toString(), HttpStatus.OK);

	}

	@RequestMapping(value = "/csf_sfzhq", method = RequestMethod.POST)
	public ResponseEntity<Object> sfzhq(HttpServletRequest request,
										   @RequestBody(required = true) String jsonStr) throws Exception {

		JSONObject injson = new JSONObject(jsonStr);
		String userid = injson.getJSONObject("params").getString("tel");

		JSONObject subjson = new JSONObject();
		switch (userid) {
			case "33":
			case "44":
			case "45":
			case "34":
			case "43":
			case "35":
			case "36":
			{
				subjson.put("身份证号", "12345678912345678*");
				break;
			}
		}

		JSONObject json = new JSONObject();

		json.put("code", "0");
		json.put("message", "成功");
		json.put("result", subjson);
		return new ResponseEntity<Object>(json.toString(), HttpStatus.OK);

	}
}
